Skip to content

Add Keystore support to OSS JDBC Driver#830

Merged
madhav-db merged 12 commits into
mainfrom
sslkeystore2
Jun 11, 2025
Merged

Add Keystore support to OSS JDBC Driver#830
madhav-db merged 12 commits into
mainfrom
sslkeystore2

Conversation

@madhav-db

@madhav-db madhav-db commented May 17, 2025

Copy link
Copy Markdown
Collaborator

Description

This PR implements SSL client certificate authentication support in the JDBC driver. The key implementation changes include:

  1. Added a new loadKeystoreOrNull method to load client keystores from the specified path, with proper validation and error handling.

  2. Added a createKeyManagers method to generate key managers from the keystores, necessary for client certificate authentication in the SSL handshake.

  3. Enhanced createSocketFactoryRegistry to support both server certificate validation (trust managers) and client certificate authentication (key managers).

  4. Modified the createRegistryFromTrustAnchors method to integrate keystore functionality with the existing truststore handling.

Testing

Unit tests
Manual testing:
Manually created a keystore file (manual-test.jks) using the keytool command line utility.
Wrote a simple Java test that attempted to establish a connection using a validly-formatted JDBC URL pointing to localhost.
The test validated several scenarios:
A successful connection attempt with the correct keystore path and password.
A failed attempt with an incorrect password, expecting a specific exception.
A failed attempt with a non-existent keystore file, expecting a different specific exception.

Additional Notes to the Reviewer

- Implemented client certificate authentication via keystore configuration parameters.
- Updated `ConfiguratorUtils` to handle loading and managing keystores.
- Enhanced unit tests to cover keystore loading and client certificate scenarios.
…method.

- Simplified key entry verification by replacing Enumeration with a stream-based approach for better readability and performance.
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated

@vikrantpuppala vikrantpuppala left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add more testing details in description on how you verified the actual key store works, i don't think just unit tests would be enough

Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
Comment thread src/main/java/com/databricks/jdbc/dbclient/impl/common/ConfiguratorUtils.java Outdated
…L/TLS errors. Update relevant classes and tests to replace DatabricksHttpException with DatabricksSSLException, ensuring proper error handling during SSL configuration and handshake processes.
…t SSL error handling instead of HTTP error. This change enhances clarity in logging and exception management related to SSL configuration failures.

@vikrantpuppala vikrantpuppala left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add testing details in the description, lgtm otherwise

@madhav-db madhav-db merged commit 333801c into databricks:main Jun 11, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants